<?php
	$fields_arr = array(
		'product_no'=>'产品货号',
        'type_name'=>'分类',
        'product_name'=>'品名',
        'factory_name'=>'厂家',
        'brand_name'=>'牌号',
        'min_volume'=>'最小交易量('.$pro_unit.')',
        'quantity'=>'数量('.$pro_unit.')',
        'freeze_quantity'=>'冻结数量('.$pro_unit.')',
        'sales_price'=>'销售价(元/'.$pro_unit.')',
        'cost_price'=>'成本价(元/'.$pro_unit.')',
        'pkg_size'=>'货品规格('.$pro_std.')',
        'delivery_way'=>'交收方式',
        'status'=>'状态',
        'repertory_name'=>'仓库',
        'operation'=>'操作',
    );
    if(!$custom_field_arr){
        $custom_field_arr = array_flip($fields_arr);
    }
    $fields_arr_new = array_merge($custom_field_arr,array_flip($fields_arr));
    $fields_arr_new = array_unique($fields_arr_new);
?>
{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}
<link rel="stylesheet" href="/res/js/framework/nestable/nestable.css">
<div class="container-fluid content-body">
    <div class="main">
        <!-- left side start-->
        <section class="left-section">
            <dl id="leftNav" data-type="product">
                <dt><i class="glyphicon glyphicon-record"></i>商品管理</dt>
               {if in_case_array('admin/product/add',$priv) || empty($priv)}
                <dd><a class="mbh" href="{url /admin/product/add}">商品发布</a></dd>
                {/if}
                {if in_case_array('admin/product/indexBySale',$priv) || empty($priv)}
                <dd><a class="mbh" href="{url /admin/product/indexBySale}">出售中的商品</a></dd>
               {/if}
                {if in_case_array('admin/product/indexByStore',$priv) || empty($priv)}
                <dd><a class="mb active" href="{url /admin/product/indexByStore}">仓库中的商品</a></dd>
                {/if}
                {if in_case_array('admin/repertory',$priv) || empty($priv)}
                 <dd><a class="mbh" href="{url /admin/repertory/index}">仓库信息</a></dd>
                {/if}
            </dl>
        </section>
        <!-- left side end-->


        <!-- main content start-->
        <section class="right-section" id="right-section">
            {include admin.inc.bread}
            <h2 class="header">{$title}</h2>
            <!-- start of inner-frame -->
            <div class="inner-iframe">
                <!-- Nav tabs -->
                <div class="inner-container">
                    <form id="J_List_Form" class="form-inline search-form" role="form">
                        <input type="hidden" name="pagesize" value="{$pagesize}">
                        <nav class="inline-form clearfix">
                            <div class="r">
                                <div class="css-select-group">
                                    <div class="css-select">
                                        <div class="chosen">
                                            <span></span>
                                            <i class="angle-down"></i>
                                            <input type="hidden" name="select_mix_option1" value="{$search_arr[select_mix_option1]}">
                                        </div>
                                        <ul style="z-index:999;">

                                            <li data-value="product_no">货号</li>
                                            <li data-value="type_name">分类</li>
                                            <li data-value="product_name">品名</li>
                                            <li data-value="factory_name">厂家</li>
                                            <li data-value="brand_name">牌号</li>

                                        </ul>
                                    </div>
                                    <input type="text" class="form-control input-sm" maxlength="{maxlength}" placeholder="关键词" name="select_mix_option_value1" value="{$search_arr[select_mix_option_value1]}">
                                </div>
                                <div class="form-group">
                                    <div class="css-select">
                                        <div class="chosen">
                                            <span></span>
                                            <i class="angle-down"></i>
                                            <input type="hidden" name="delivery_way" value="{$search_arr[delivery_way]}">
                                        </div>
                                        <ul>
                                            <li data-value="all">-交收方式-</li>
                                            <li data-value="0">卖家配送</li>
                                            <li data-value="1">买家自提</li>
                                        </ul>
                                    </div>
                                </div>
                                <input type="hidden" name="order" value="{$order}">
                                <button type="submit" class="btnlg mb">搜索</button>
                                <button type="button" class="btnlg mb" id="J_Export_btn">导出Excel</button>
                                <button type="button" class="btnlg mb" id="defined">配置列表项</button>
                            </div>

                            </nav>
                        <!-- search form end -->
                    <!--</form>
                    <form id="J_List_Form">-->
                        <div class="table-responsive">
                            <table id="J_ListTable" class="table  table-hover  table-striped">
                                <thead>
                                <tr>
                                    <th width="20"><label class="css-checkbox"><input type="checkbox" class="check-all" /><span></span></label></th>
                                    {loop $custom_field_arr $k $v}
                                    <th>{$fields_arr[$v]}</th>
                                    {/loop}
                                </tr>
                                </thead>
                                <tbody>
                                {if empty($items)}
                                <tr>
                                    <td style="text-align:center;" colspan="8" class="empty-table-td">{$emptyRecord}
                                    </td>
                                </tr>
                                {/if}
                                {loop $items $value}
                                <tr data-id="{$value[id]}">
                                    <td>
                                        <label class="css-checkbox"><input type="checkbox" name="ids[]" value="{$value[id]}"/><span></span></label>
                                    </td>
                                    {loop $custom_field_arr $v}
                                    {if $v=='operation'}
                                    <td>
                                        {if in_array('admin/product/edit',$priv) || empty($priv)}
                                        <a href="{$edit_url}?id={$value[id]}&from={$from}" class="btnsm-primary">
                                            编辑</a>
                                        {/if}
                                        {if in_array('admin/product/onshelf',$priv) || empty($priv)}
                                        <a href="javascript:;" class="btnsm-success item-bind js-on">上架</a>
                                        {/if}
                                        {if in_array('admin/product/delete',$priv) || empty($priv)}
                                        <a href="{$delete_url}?id={$value[id]}"
                                           class="btnsm-danger item-remove">删除</a>
                                        {/if}
                                    </td>
                                    {else}
                                    <td>{$value[$v]}</td>
                                    {/if}
                                    {/loop}
                                </tr>
                                {/loop}
                            </table>
                        </div>
                    </form>
                   <div class="footer">
                       <!-- 批量操作 start -->
                        <div class="btn-group dropup" data-act="operateAll">
                            <button class="btnlg mb dropdown-toggle" data-toggle="dropdown" aria-expanded="true" disabled>批量操作<span class="caret"></span></button>
                            {if in_array('admin/product/onshelf',$priv) || empty($priv)}
                            <ul name="action-bacth-select" class="dropdown-menu" role="menu">
                                <li><a data-action="onNew">上架</a></li>
                                 {/if}
                                {if in_array('admin/product/delete',$priv) || empty($priv)} 
                                <li><a data-action="deleteNew">删除</a></li>                
                            </ul>
                            {/if}
                        </div>
                       <!--  批量操作 end -->
                        {$pagemenu}
                   </div>
                </div>
            </div>
        </section>
    </div>
</div>

<!--footer section start-->
{include admin.inc.footer}
<!--footer section end-->

<!--tmpl-script-->

<!-- template -->
<!--自定义start-->
<script id="defined_table" type="text/html">
    <div>
        <form id="defined_edit" class="form-horizontal">
            <input type="hidden" name="url" value="{$module}/{$action}/{$method}">
            <div class="de_title"><i></i>拖动改变顺序</div>
            <div class="cf">
                <div class="dd" id="nestable3">
                    <ol class="dd-list">
                        {loop $fields_arr_new $v}
                        <li class="dd-item dd3-item" data-id="{$v}">
                            <div class="dd-handle dd3-handle"></div><div class="dd3-content">
                            <label class="css-checkbox">
                                <input type="checkbox" {if in_array($v,$custom_field_arr)}checked="checked"{/if} name="field_arr[]" value="{$v}">
                                <span>{$fields_arr[$v]}</span>
                            </label>
                        </div>
                        </li>
                        {/loop}
                    </ol>
                </div>
            </div>
        </form>
    </div>
</script>
<!--自定义end-->

<script id="editpanel" type="text/html">
    <div>
        <form id="editpanel-form" class="form-horizontal">
            <div class="row">&nbsp</div>
            <!--tmpl-fieldlist-->

            <!-- input -->
            <div class="form-group">
                <label>产品货号 </label>
                <input dtype="" class="form-control" maxlength="20" name="data[product_no]" placeholder="产品货号" required
                       cname="产品货号" value="{[product_no]}"/>
            </div>
            <p class="help-block"></p>

            <!-- password -->
            <div class="form-group">
                <label>计价类型</label>
                <input type="password" placeholder="计价类型" name="data[valuation_type]" id="inputvaluation_type"
                       class="form-control" value="{[valuation_type]}">
            </div>
            <p class="help-block"></p>

            <!-- input -->
            <div class="form-group">
                <label>数量(库存数量) </label>
                <input dtype="" class="form-control" maxlength="{maxlength}" name="data[quantity]"
                       placeholder="数量(库存数量)" required cname="数量(库存数量)" value="{[quantity]}"/>
            </div>
            <p class="help-block"></p>

            <!-- input -->
            <div class="form-group">
                <label>最小交易量 </label>
                <input dtype="" class="form-control" maxlength="{maxlength}" name="data[min_volume]" placeholder="最小交易量"
                       required cname="最小交易量" value="{[min_volume]}"/>
            </div>
            <p class="help-block"></p>

            <!-- input -->
            <div class="form-group">
                <label>销售价 </label>
                <input dtype="" class="form-control" maxlength="{maxlength}" name="data[sales_price]" placeholder="销售价"
                       required cname="销售价" value="{[sales_price]}"/>
            </div>
            <p class="help-block"></p>

            <!-- input -->
            <div class="form-group">
                <label>成本价 </label>
                <input dtype="" class="form-control" maxlength="{maxlength}" name="data[cost_price]" placeholder="成本价"
                       required cname="成本价" value="{[cost_price]}"/>
            </div>
            <p class="help-block"></p>


            <!--tmpl-assocfields-->
        </form>
    </div>
</script>

<!-- pagescript -->
<script type="text/javascript">
    seajs.use("admin/productindex", function (parameter) {

        /**--tmpl-templatejavascript--**/

        <!--tmpl-templatejavascript-->
        parameter.detailUrl = "{$detail_url}";
        parameter.doDeleteUrl = "{$do_delete_url}";
        parameter.editUrl = "{$do_edit_url}";
        parameter.doOnShelfUrl = "{url admin/product/do_onShelf}";

        parameter.image_search_url = "{$image_search_url}";
        parameter.image_list_url = "{$image_list_url}";

        parameter.init();
    });
</script>


<script id="assocpage" type="text/html">
    <div class="text-right">
        <ul class="pagination blog-pagination">
            <li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li>
            {[loop pages page]}

            <li {[if curr== page]}class="active" {[
            /if]}><a class="assoc-page" data-page="{[page]}" href="javascript:void(0)">{[page]}</a></li>

            {[/loop]}
            <li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li>
        </ul>
    </div>
</script>
</body>
</html>
